export const storage = {
    set<T>(key: string, value: T): void {
        localStorage.setItem(key, JSON.stringify(value));
    },

    get<T>(key: string): T | null {
        const value = localStorage.getItem(key);
        if (value) {
            try {
                return JSON.parse(value) as T;
            } catch (e) {
                console.error(`Error parsing localStorage item "${key}":`, e);
                return null;
            }
        }
        return null;
    },

    remove(key: string): void {
        localStorage.removeItem(key);
    },
}
